package com.leyou.seckill.controller;

import com.leyou.common.vo.PageResult;
import com.leyou.seckill.dto.OrderSecKillDTO;
import com.leyou.seckill.dto.SeckillPolicyDTO;
import com.leyou.seckill.entity.TbSeckillPolicy;
import com.leyou.seckill.service.SecKillService;
import com.leyou.time.client.TimeClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 秒杀 后台管理操作
 *
 * @author
 */
@RestController
public class SecKillPortalController {

    @Autowired
    private TimeClient timeClient;

    @Autowired
    private SecKillService secKillService;

    ///portal/time
    @GetMapping("/portal/time")
    public ResponseEntity<String> getTime(){
        String nowTime = timeClient.getNowTime();
        return ResponseEntity.ok(nowTime);
    }

    @PostMapping("/portal/secKill")
    public ResponseEntity<Long> saveSeckillOrder(@RequestBody OrderSecKillDTO orderSecKillDTO){
       Long orderId = secKillService.saveSeckillOrder(orderSecKillDTO);
        return ResponseEntity.ok(orderId);
    }



}
